//
//  HYViewControllerForSingerMore.m
//  TTLestening
//
//  Created by dllo on 16/3/29.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "HYViewControllerForSingerMore.h"
#import "HYModelForSingerMore.h"
#import "HYTableViewCellForSingerMore.h"
#import "NetworkingHandlerOfBlock.h"

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface HYViewControllerForSingerMore () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableViewForMore;
@property (nonatomic, strong) NSMutableArray *arrForMore;

@end

@implementation HYViewControllerForSingerMore


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.arrForMore = [NSMutableArray array];
    
    self.navigationItem.title = @"音乐专题";
    
    [self.navigationController.navigationBar setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor],NSFontAttributeName : [UIFont fontWithName:@"AmericanTypewriter-Bold" size:22],}];


    [self handleData];
    [self creteTableView];
}

- (void)handleData {
    
    NSString *str = @"http://api.dongting.com/misc/musiczone/new?app=ttpod&v=v8.1.5.2016022418&user_id=0&mid=iPad4%2C4&f=f320&s=s330&imsi=&hid=&splus=9.2&active=1&net=2&openudid=2928af1fecbb94c32045ea1742d7f5be6defe28e&idfa=87EE45D3-F1BC-49C6-AD99-E17773876586&utdid=Vu9EaFGgHV4DAPqTc15UrKj8&alf=201200&bundle_id=com.ttpod.music&latitude=&longtitude=";
    
    [NetworkingHandler networkingNOSaveWithUrl:str completeHandle:^(NSURLResponse *response, NSData *data, id result) {
       
        NSArray *arr = [result objectForKey:@"data"];

        for (NSDictionary *dic in arr) {
            
            HYModelForSingerMore *model = [[HYModelForSingerMore alloc] init];
            
            [model setValuesForKeysWithDictionary:dic];
            
            [self.arrForMore addObject:model];
        }
        
        [self.tableViewForMore reloadData];
        
    }];
//    NSLog(@"%@",self.arrForMore);
}

- (void)creteTableView {
    
    self.tableViewForMore = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 49) style:UITableViewStylePlain];
    
    [self.view addSubview:self.tableViewForMore];
    
    self.tableViewForMore.dataSource = self;
    self.tableViewForMore.delegate = self;
    
    [self.tableViewForMore registerNib:[UINib nibWithNibName:@"HYTableViewCellForSingerMore" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"Morepool"];

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.arrForMore.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 250;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    HYModelForSingerMore *model = [self.arrForMore objectAtIndex:indexPath.item];
    
   HYTableViewCellForSingerMore *cell = [tableView dequeueReusableCellWithIdentifier:@"Morepool" forIndexPath:indexPath];
    
    [cell passMoldel:model];
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
